import _axios from './axios';

// 添加购物车
function addgoods(goods_id,num) {
    return _axios({
        url: "/shoppingCart",
        method:"POST",
        data: {
            goods_id,
            num
        },
        headers:{
            "x-token":sessionStorage.getItem("token")
        }
    })
}

// 更新购物车
function updategoods(id,num) {
    return _axios({
        url: "/shoppingCart/"+id,
        method:"PUT",
        data: {
            id,
            num
        },
        headers:{
            "x-token":sessionStorage.getItem("token")
        }
    })
}

// 删除购物车
function deletegoods(id) {
    return _axios({
        url: "/shoppingCart/"+id,
        method:"DELETE",
        data: {
            id
        },
        headers:{
            "x-token":sessionStorage.getItem("token")
        }
    })
}

// 获取购物车
function getgoods() {
    return _axios({
        url: "/shoppingCart",
        params: {
            "project_id": 151,
        },
        headers:{
            "x-token":sessionStorage.getItem("token")
        }
    })
}

export  {addgoods,updategoods,deletegoods,getgoods};